package com.software.levelupandroid.systemTask.presenter;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import com.software.levelupandroid.entity.SystemTask;
import com.software.levelupandroid.service.NotionService;
import com.software.levelupandroid.systemTask.CallBack;
import com.software.levelupandroid.systemTask.model.IModel;
import com.software.levelupandroid.systemTask.model.TaskModel;
import com.software.levelupandroid.systemTask.view.IView;

import java.util.List;

/**
 * @Description 任务发布的Presenter
 * @Author wuruoheng
 * @CreateTime 2024年06月08日 09:12:57
 */
public class TaskPresenter implements IPresenter, CallBack {
    private IView systemTaskView;
    private IModel systemTaskModel;

    public TaskPresenter(IView taskIssueView) {
        this.systemTaskView = taskIssueView;
        systemTaskModel = new TaskModel();
    }

    @Override
    public void insertSystemTask(int systemTaskId,String time,String startDate,String endDate, Context context) {
        systemTaskModel.insertSystemTask(systemTaskId,time,startDate,endDate, context, this);
    }


    @Override
    public void updateTask(SystemTask task, Context context) {
        systemTaskModel.updateTask(task, context, this);
    }

    public void isFinishTask(SystemTask task, Context context){
        systemTaskModel.updateTask(task, context, new CallBack() {
            @Override
            public void onSuccess(SystemTask task) {
                systemTaskView.isFinishSuccess(task);
            }

            @Override
            public void onFailure(String msg) {
                systemTaskView.isFinishFailure(msg);
            }
        });
    }

    @Override
    public void deleteTask(SystemTask task, Context context) {
        systemTaskModel.deleteTask(task, context, new CallBack() {
            @Override
            public void onSuccess(SystemTask task) {
                systemTaskView.deleteTaskSuccess(task);
            }

            @Override
            public void onFailure(String msg) {
                systemTaskView.deleteTaskFailure(msg);
            }
        });
    }

    @Override
    public void onSuccess(SystemTask task) {
        systemTaskView.issueTaskSuccess(task);
    }

    @Override
    public void onFailure(String msg) {
        systemTaskView.issueTaskFailure(msg);
    }
}
